<!DOCTYPE html>
<html>
<head>
	<title>注册</title>
	<meta charset="utf-8">
	<meta name = "viewport" content ="initial-scale=1.0,maximum-scale=1,user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="telephone=no" name="format-detection">
	<link rel="stylesheet" type="text/css" href="/resource/web/css/reset.css">
	<link rel="stylesheet" type="text/css" href="/resource/web/css/login.css">
	<script type="text/javascript" src="/resource/web/js/flexible.js"></script>
	<script type="text/javascript" src="/resource/web/js/jquery-1.11.1.min.js"></script>
</head>
<?php
	if(empty($mobile)||empty($captcha)){
		echo "<script>alert('数据提交错误');location.href='/Web/register.html';</script>";die;

	}
?>
<body>
    <div class="title">
    	<p>注册</p>
    	<a href="javascript:history.go(-1);"><img src="/resource/web/img/newhead/path_7_copy.png"></a>

    </div>
	<form action="/Web/verify_register" method="post" onsubmit="return check_all()">
    <div class="set-pwd">
			<input type="hidden" value="{{$mobile}}" name="mobile" id="mobile">
			<input type="hidden" value="{{$captcha}}" name="captcha" id="captcha">
			<p><input type="password" name="pwd" id="pwd" placeholder="6-16个字符，由字母+数字和符号两种以上组合" onblur="check_pwd()"></p>
			<p class="myhead">
				我有推荐人<img src="/resource/web/img/login/tg.png">
				<input type="text" name="invite_phone" id="invite_phone" placeholder="推荐人邀请码" onblur="check_invite()">
			</p>

    </div>
	<input type="submit" value="完成"  class="rg-fina-btn">
	</form>
</body>
</html>
<script>
	//验证密码
	function check_pwd(){
		var pwd = document.getElementById('pwd').value;
		var reg_pwd=/^(?![\d]+$)(?![a-zA-Z]+$)(?![!#$%^&*]+$)[\da-zA-Z!#$%^&*]{6,16}$/
		if(pwd){
			if(reg_pwd.test(pwd)) {
				return true
			}else{
				alert('6-16个字符，由字母+数字和符号两种以上组合');
				return false
			}
		}else{
			alert('密码不能为空');
			return false
		}
	}

	function check_invite()
	{
		var invite_phone = document.getElementById('invite_phone').value;
		var reg_invite = /^\d{6}$/;
		var status = false;
		if(invite_phone){
			if(reg_invite.test(invite_phone)){
				var ajax = new XMLHttpRequest();
				ajax.onreadystatechange = function () {
					if (ajax.readyState == 4) {
						if (ajax.responseText == 1) {
							status = true
						}else{
							alert('邀请人验证码不存在')
						}
					}
				}
				//与服务器建立连接
				ajax.open('post', '/js_verify_register', false);
				ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				//处理请求
				ajax.send('invite_phone=' + invite_phone);
				return status
			}else{
				alert('邀请码格式错误')
				return false
			}
		}
	}

	function check_all(){
		return (check_pwd()&&check_invite())
	}
</script>